﻿<?php require_once('../Connections/hitekforyou.php'); ?>
<?php
require_once('checklogin.php');
//MX Widgets3 include
require_once('../includes/wdg/WDG.php');

error_reporting(0);
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("../");

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listquangcao1 = new TFI_TableFilter($conn_hitekforyou, "tfi_listquangcao1");
$tfi_listquangcao1->addColumn("quangcao.idQuangCao", "NUMERIC_TYPE", "idQuangCao", "=");
$tfi_listquangcao1->addColumn("quangcao.TenCongTyQC", "STRING_TYPE", "TenCongTyQC", "%");
$tfi_listquangcao1->addColumn("quangcao.SDT", "STRING_TYPE", "SDT", "%");
$tfi_listquangcao1->addColumn("quangcao.TGKT", "DATE_TYPE", "TGKT", "=");
$tfi_listquangcao1->Execute();

// Sorter
$tso_listquangcao1 = new TSO_TableSorter("rsquangcao1", "tso_listquangcao1");
$tso_listquangcao1->addColumn("quangcao.idQuangCao");
$tso_listquangcao1->addColumn("quangcao.TenCongTyQC");
$tso_listquangcao1->addColumn("quangcao.SDT");
$tso_listquangcao1->addColumn("quangcao.TGKT");
$tso_listquangcao1->setDefault("quangcao.idQuangCao");
$tso_listquangcao1->Execute();

// Navigation
$nav_listquangcao1 = new NAV_Regular("nav_listquangcao1", "rsquangcao1", "../", $_SERVER['PHP_SELF'], 10);

//NeXTenesio3 Special List Recordset
$maxRows_rsquangcao1 = $_SESSION['max_rows_nav_listquangcao1'];
$pageNum_rsquangcao1 = 0;
if (isset($_GET['pageNum_rsquangcao1'])) {
  $pageNum_rsquangcao1 = $_GET['pageNum_rsquangcao1'];
}
$startRow_rsquangcao1 = $pageNum_rsquangcao1 * $maxRows_rsquangcao1;

// Defining List Recordset variable
$NXTFilter_rsquangcao1 = "1=1";
if (isset($_SESSION['filter_tfi_listquangcao1'])) {
  $NXTFilter_rsquangcao1 = $_SESSION['filter_tfi_listquangcao1'];
}
// Defining List Recordset variable
$NXTSort_rsquangcao1 = "quangcao.idQuangCao";
if (isset($_SESSION['sorter_tso_listquangcao1'])) {
  $NXTSort_rsquangcao1 = $_SESSION['sorter_tso_listquangcao1'];
}
mysql_select_db($database_hitekforyou, $hitekforyou);

$query_rsquangcao1 = "SELECT quangcao.idQuangCao, quangcao.TenCongTyQC, quangcao.SDT, quangcao.TGKT FROM quangcao WHERE {$NXTFilter_rsquangcao1} ORDER BY {$NXTSort_rsquangcao1}";
$query_limit_rsquangcao1 = sprintf("%s LIMIT %d, %d", $query_rsquangcao1, $startRow_rsquangcao1, $maxRows_rsquangcao1);
$rsquangcao1 = mysql_query($query_limit_rsquangcao1, $hitekforyou) or die(mysql_error());
$row_rsquangcao1 = mysql_fetch_assoc($rsquangcao1);

if (isset($_GET['totalRows_rsquangcao1'])) {
  $totalRows_rsquangcao1 = $_GET['totalRows_rsquangcao1'];
} else {
  $all_rsquangcao1 = mysql_query($query_rsquangcao1);
  $totalRows_rsquangcao1 = mysql_num_rows($all_rsquangcao1);
}
$totalPages_rsquangcao1 = ceil($totalRows_rsquangcao1/$maxRows_rsquangcao1)-1;
//End NeXTenesio3 Special List Recordset

$nav_listquangcao1->checkBoundries();

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_hitekforyou);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "GET", "KT_logout_now");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "login.php");
// Add columns
// End of logout transaction instance

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="quantri.css" rel="stylesheet" type="text/css" />
<script src="../AC_RunActiveContent.js" type="text/javascript"></script>

<title>Quản trị web HitekForYou</title>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script>
<style type="text/css">
  /* Dynamic List row settings */
  .KT_col_idQuangCao {
	width:100px;
	overflow:hidden;
}
  .KT_col_TenCongTyQC {
	width:150px;
	overflow:hidden;
}
  .KT_col_SDT {
	width:80px;
	overflow:hidden;
}
  .KT_col_TGKT {
	width:120px;
	overflow:hidden;
}
</style>
<script type="text/javascript" src="../includes/common/js/sigslot_core.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="../includes/wdg/classes/Calendar.js"></script>
<script type="text/javascript" src="../includes/wdg/classes/SmartDate.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar_stripped.js"></script>
<script type="text/javascript" src="../includes/wdg/calendar/calendar-setup_stripped.js"></script>
<script src="../includes/resources/calendar.js"></script>
</head>

<body>

<?php include("admin_template/header.php"); ?>
<?php include("admin_template/admin_banner.php"); ?> 
<table id="main" width="990" border="1" align="center" cellpadding="0" cellspacing="0">
 <tr>
    <td width="200" align="left" valign="top" bgcolor="#66CC00" id="cottrai">
      <div align="left">
      <?php include("menu.php"); ?>  
      </div>       </td>
    <td id="cotphai" width="790" align="left" valign="top" bgcolor="#CCFF00">
     
  
   
    <div class="KT_tng" id="listquangcao1">
      <h1> Danh sách quảng cáo
        <?php
  $nav_listquangcao1->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
      </h1>
      <div class="KT_tnglist">
        <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
          <div class="KT_options"> <a href="<?php echo $nav_listquangcao1->getShowAllLink(); ?>">Hiện
                <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listquangcao1'] == 1) {
?>
                  <?php echo $_SESSION['default_max_rows_nav_listquangcao1']; ?>
                  <?php 
  // else Conditional region1
  } else { ?>
                  tất cả
                  <?php } 
  // endif Conditional region1
?>
                dữ liệu</a> &nbsp;
            &nbsp;
                <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listquangcao1'] == 1) {
?>
                  <a href="<?php echo $tfi_listquangcao1->getResetFilterLink(); ?>">Đóng bộ lọc</a>
                  <?php 
  // else Conditional region2
  } else { ?>
                  <a href="<?php echo $tfi_listquangcao1->getShowFilterLink(); ?>">Hiện bộ lọc</a>
                  <?php } 
  // endif Conditional region2
?>
          </div>
          <table cellpadding="2" cellspacing="0" class="KT_tngtable">
            <thead>
              <tr class="KT_row_order">
                <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
                </th>
                <th id="idQuangCao" class="KT_sorter KT_col_idQuangCao <?php echo $tso_listquangcao1->getSortIcon('quangcao.idQuangCao'); ?>"> <a href="<?php echo $tso_listquangcao1->getSortLink('quangcao.idQuangCao'); ?>">ID Quảng cáo</a> </th>
                <th id="TenCongTyQC" class="KT_sorter KT_col_TenCongTyQC <?php echo $tso_listquangcao1->getSortIcon('quangcao.TenCongTyQC'); ?>"> <a href="<?php echo $tso_listquangcao1->getSortLink('quangcao.TenCongTyQC'); ?>">Tên Công ty Quảng Cáo</a> </th>
                <th id="SDT" class="KT_sorter KT_col_SDT <?php echo $tso_listquangcao1->getSortIcon('quangcao.SDT'); ?>"> <a href="<?php echo $tso_listquangcao1->getSortLink('quangcao.SDT'); ?>">Số điện thoại</a> </th>
                <th id="TGKT" class="KT_sorter KT_col_TGKT <?php echo $tso_listquangcao1->getSortIcon('quangcao.TGKT'); ?>"> <a href="<?php echo $tso_listquangcao1->getSortLink('quangcao.TGKT'); ?>">Thời gian kết thúc</a> </th>
                <th>&nbsp;</th>
              </tr>
              <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listquangcao1'] == 1) {
?>
                <tr class="KT_row_filter">
                  <td>&nbsp;</td>
                  <td><input type="text" name="tfi_listquangcao1_idQuangCao" id="tfi_listquangcao1_idQuangCao" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listquangcao1_idQuangCao']); ?>" size="10" maxlength="100" /></td>
                  <td><input type="text" name="tfi_listquangcao1_TenCongTyQC" id="tfi_listquangcao1_TenCongTyQC" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listquangcao1_TenCongTyQC']); ?>" size="32" maxlength="255" /></td>
                  <td><input type="text" name="tfi_listquangcao1_SDT" id="tfi_listquangcao1_SDT" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listquangcao1_SDT']); ?>" size="20" maxlength="20" /></td>
                  <td><input name="tfi_listquangcao1_TGKT" id="tfi_listquangcao1_TGKT" value="<?php echo @$_SESSION['tfi_listquangcao1_TGKT']; ?>" size="10" maxlength="22" wdg:mondayfirst="false" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:singleclick="false" wdg:restricttomask="no" wdg:readonly="true" /></td>
                  <td><input type="submit" name="tfi_listquangcao1" value="Lọc" /></td>
                </tr>
                <?php } 
  // endif Conditional region3
?>
            </thead>
            <tbody>
              <?php if ($totalRows_rsquangcao1 == 0) { // Show if recordset empty ?>
                <tr>
                  <td colspan="6"><?php echo NXT_getResource("Dữ liệu đang rỗng hoặc từ khóa lọc của bạn quá dài."); ?></td>
                </tr>
                <?php } // Show if recordset empty ?>
              <?php if ($totalRows_rsquangcao1 > 0) { // Show if recordset not empty ?>
                <?php do { ?>
                  <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
                    <td><input type="checkbox" name="kt_pk_quangcao" class="id_checkbox" value="<?php echo $row_rsquangcao1['idQuangCao']; ?>" />
                        <input type="hidden" name="idQuangCao" class="id_field" value="<?php echo $row_rsquangcao1['idQuangCao']; ?>" />
                    </td>
                    <td><div class="KT_col_idQuangCao"><?php echo KT_FormatForList($row_rsquangcao1['idQuangCao'], 20); ?></div></td>
                    <td><div class="KT_col_TenCongTyQC"><?php echo KT_FormatForList($row_rsquangcao1['TenCongTyQC'], 40); ?></div></td>
                    <td><div class="KT_col_SDT"><?php echo KT_FormatForList($row_rsquangcao1['SDT'], 20); ?></div></td>
                    <td><div class="KT_col_TGKT"><?php echo KT_formatDate($row_rsquangcao1['TGKT']); ?></div></td>
                    <td><a class="KT_edit_link" href="FormQuangCao.php?idQuangCao=<?php echo $row_rsquangcao1['idQuangCao']; ?>&amp;KT_back=1">Sửa</a> <a class="KT_delete_link" href="#delete">Xóa</a> </td>
                  </tr>
                  <?php } while ($row_rsquangcao1 = mysql_fetch_assoc($rsquangcao1)); ?>
                <?php } // Show if recordset not empty ?>
            </tbody>
          </table>
          <div class="KT_bottomnav">
            <div>
              <?php
            $nav_listquangcao1->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
            </div>
          </div>
          <div class="KT_bottombuttons">
            <div class="KT_operations">  <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;">Xóa nhiều</a> </div>
            <span>&nbsp;</span>
           
            <a class="KT_additem_op_link" href="FormQuangCao.php?KT_back=1" onclick="return nxt_list_additem(this)">Thêm</a> </div>
        </form>
      </div>
      <br class="clearfixplain" />
    </div>
    <p>&nbsp;</p>
  </tr>
</table>
<?php include("admin_template/footer.php"); ?>  
</body>
</html>
<?php
mysql_free_result($rsquangcao1);
?>

